package com.zzh.demo.core.common.utils;


import com.zzh.demo.core.model.LoginUser;

import javax.servlet.http.HttpSession;

import static com.zzh.demo.core.common.constants.Constants.SESSION_LOGIN_USER;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_ACCOUNT;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_CURRENT_PROJECT_ID;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_ID;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_NAME;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_ROLE_ID;
import static com.zzh.demo.core.common.constants.Constants.SESSION_USER_TYPE;


/**
 * description： <br>
 * createTime: 2018/2/2610:33 <br>
 *
 * @author zzh
 */
public class SessionUtils {


    public static void setSession(HttpSession session, LoginUser loginUser) {
        session.setAttribute(SESSION_LOGIN_USER, loginUser);
        session.setAttribute(SESSION_USER_ID, loginUser.getUserId());
        session.setAttribute(SESSION_USER_NAME, loginUser.getUserName());
        session.setAttribute(SESSION_USER_CURRENT_PROJECT_ID, loginUser.getCurrentProjectId());
        session.setAttribute(SESSION_USER_ACCOUNT, loginUser.getUserAccount());
        session.setAttribute(SESSION_USER_ROLE_ID, loginUser.getRoleIds());
        session.setAttribute(SESSION_USER_TYPE, loginUser.getUserType());
    }
}
